﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "GameplayEffect.h"
#include "StarrySkyEffectActor.generated.h"

class UAbilitySystemComponent;
class UGameplayEffect;
//创建添加策略枚举
UENUM(BlueprintType)
enum class EEffectApplicationPolicy : uint8
{
	//重叠的时候添加新的效果
	ApplyOnOverlap,
	//重叠结束的时候添加新的效果
	ApplyOnEndOverlap,
	//不添加任何新效果
	DoNotApply
};

//移除的策略枚举
UENUM(BlueprintType)
enum class EEffectRemovalPolicy : uint8
{
	//移除的时候移除效果
	RemoveOnEndOverlap,
	//不移除效果
	DoNotRemove
};

class UGameplayEffect;
class USphereComponent;

UCLASS()
class STARRYSKY_API AStarrySkyEffectActor : public AActor
{
	GENERATED_BODY()

public:
	AStarrySkyEffectActor();

protected:
	virtual void BeginPlay() override;
	//对象应用游戏效果，第一个参数是目标对象，第二个参数是游戏效果类父类继承自UGameplayEffect
	UFUNCTION(BlueprintCallable)
	void ApplyEffectToTarget(AActor* TargetActor, TSubclassOf<UGameplayEffect> GameplayEffectClass);

	UFUNCTION(BlueprintCallable)
	void onOverlap(AActor* TargetActor);
	
	UFUNCTION(BlueprintCallable)
	void onEndOverlap(AActor* TargetActor);

	//添加一个游戏效果的实例类，用于生成对应的游戏效果
	//实时效果
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	TSubclassOf<UGameplayEffect> InstantGamePlayEffectClass;
	//实时效果的添加策略
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	EEffectApplicationPolicy InstantEffectApplicationPolicy = EEffectApplicationPolicy::DoNotApply;
	//持续时间效果
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	TSubclassOf<UGameplayEffect> DurationGamePlayEffectClass;
	//持续时间效果的添加策略
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	EEffectApplicationPolicy DurationEffectApplicationPolicy = EEffectApplicationPolicy::DoNotApply;
	//无限效果
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	TSubclassOf<UGameplayEffect> InfiniteGamePlayEffectClass;
	//无限效果的添加策略
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	EEffectApplicationPolicy InfiniteEffectApplicationPolicy = EEffectApplicationPolicy::DoNotApply;
	//无限效果的移除策略
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
	EEffectRemovalPolicy InfiniteEffectRemovalPolicy = EEffectRemovalPolicy::RemoveOnEndOverlap;

	TMap<FActiveGameplayEffectHandle, UAbilitySystemComponent*> ActiveEffectHandles;//保存所有的效果句柄与能力系统的对应关系，这里可能是很多物体与该效果Actor触发重叠
	
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Applied Effects")
    float ActorLevel=1.f;//效果对象的等级
private:
};
